import re


def verify_phone_number(phone_number):
    # 定义三大运营商的手机号正则表达式
    cmcc_pattern = r'^(134[0-8]|13[5-9]|147|148|15[0-27-9]|165|172|178|18[2-478]|19[5689])\d{8}$'
    cucc_pattern = r'^(13[0-2]|145|15[56]|166|167|17[15-7]|18[56])\d{8}$'
    ctcc_pattern = r'^(133|149|153|162|173|1740[0-5]|177|18[019]|19[0139])\d{8}$'
    # 定义虚拟运营商的手机号正则表达式
    virtual_pattern = r'^(170[0-25-9]|171)\d{7}$'

    if re.match(cmcc_pattern, phone_number):
        return "中国移动", "公众移动通信服务"
    elif re.match(cucc_pattern, phone_number):
        return "中国联通", "公众移动通信服务"
    elif re.match(ctcc_pattern, phone_number):
        return "中国电信", "公众移动通信服务"
    elif re.match(virtual_pattern, phone_number):
        return "虚拟运营商", "移动通信转售服务"
    else:
        return None, None


while True:
    phone = input("请输入要验证的手机号: ")
    operator, service_type = verify_phone_number(phone)
    if operator and service_type:
        print(f"手机号 {phone} 是合规的，属于{operator}，服务类别为{service_type}。")
        break
    else:
        print(f"手机号 {phone} 不合规，请重新输入。")
